* Make Targets in Cygnus Tree:: Make Targets in Cygnus Tree.
* Target libiberty:: Target libiberty
File: configure.info, Node: Host and Target Libraries, Next: Target Library Configure Scripts, Up: Cross Tools in the Cygnus Tree
Host and Target Libraries
-------------------------
The Cygnus tree distinguishes host libraries from target libraries.
Host libraries are built with the compiler used to build the programs
which run on the host, which is called the host compiler. This includes
libraries such as `bfd' and `tcl'. These libraries are built with the
host compiler, and are linked into programs like the binutils or gcc
which run on the host.
Target libraries are built with the target compiler. If gcc is
present in the source tree, then the target compiler is the gcc that is
built using the host compiler. Target libraries are libraries such as
`newlib' and `libstdc++'. These libraries are not linked into the host
programs, but are instead made available for use with programs built
with the target compiler.
For the rest of this section, assume that gcc is present in the
source tree, so that it will be used to build the target libraries.
There is a complication here. The configure process needs to know
which compiler you are going to use to build a tool; otherwise, the
feature tests will not work correctly. The Cygnus tree handles this by
not configuring the target libraries until the target compiler is
built. In order to permit everything to build using a single
`configure'/`make', the configuration of the target libraries is
actually triggered during the make step.
When the target libraries are configured, the `--target' option is
not used. Instead, the `--host' option is used with the argument of
the `--target' option for the overall configuration. If no `--target'
option was used for the overall configuration, the `--host' option will
be passed with the output of the `config.guess' shell script. Any
`--build' option is passed down unchanged.
This translation of configuration options is done because since the
target libraries are compiled with the target compiler, they are being
built in order to run on the target of the overall configuration. By
the definition of host, this means that their host system is the same as
the target system of the overall configuration.
The same process is used for both a native configuration and a cross
configuration. Even when using a native configuration, the target
libraries will be configured and built using the newly built compiler.
This is particularly important for the C++ libraries, since there is no
reason to assume that the C++ compiler used to build the host tools (if
there even is one) uses the same ABI as the g++ compiler which will be
used to build the target libraries.
There is one difference between a native configuration and a cross
configuration. In a native configuration, the target libraries are
normally configured and built as siblings of the host tools. In a cross
configuration, the target libraries are normally built in a subdirectory
whose name is the argument to `--target'. This is mainly for
historical reasons.
To summarize, running `configure' in the Cygnus tree configures all
the host libraries and tools, but does not configure any of the target
libraries. Running `make' then does the following steps:
* Build the host libraries.
* Build the host programs, including gcc. Note that we call gcc
both a host program (since it runs on the host) and a target
compiler (since it generates code for the target).
* Using the newly built target compiler, configure the target
libraries.
* Build the target libraries.
The steps need not be done in precisely this order, since they are
actually controlled by `Makefile' targets.
File: configure.info, Node: Target Library Configure Scripts, Next: Make Targets in Cygnus Tree, Prev: Host and Target Libraries, Up: Cross Tools in the Cygnus Tree
Target Library Configure Scripts
--------------------------------
There are a few things you must know in order to write a configure
script for a target library. This is just a quick sketch, and beginners
shouldn't worry if they don't follow everything here.
The target libraries are configured and built using a newly built
target compiler. There may not be any startup files or libraries for
this target compiler. In fact, those files will probably be built as
part of some target library, which naturally means that they will not
exist when your target library is configured.
This means that the configure script for a target library may not use
any test which requires doing a link. This unfortunately includes many
useful autoconf macros, such as `AC_CHECK_FUNCS'. autoconf macros
which do a compile but not a link, such as `AC_CHECK_HEADERS', may be
used.
This is a severe restriction, but normally not a fatal one, as target
libraries can often assume the presence of other target libraries, and
thus know which functions will be available.
As of this writing, the autoconf macro `AC_PROG_CC' does a link to
make sure that the compiler works. This may fail in a target library,
so target libraries must use a different set of macros to locate the
compiler. See the `configure.in' file in a directory like `libiberty'
or `libgloss' for an example.
As noted in the previous section, target libraries are sometimes
built in directories which are siblings to the host tools, and are
sometimes built in a subdirectory. The `--with-target-subdir' configure
option will be passed when the library is configured. Its value will be
an empty string if the target library is a sibling. Its value will be
the name of the subdirectory if the target library is in a subdirectory.
If the overall build is not a native build (i.e., the overall
configure used the `--target' option), then the library will be
configured with the `--with-cross-host' option. The value of this
option will be the host system of the overall build. Recall that the
host system of the library will be the target of the overall build. If
the overall build is a native build, the `--with-cross-host' option
will not be used.
A library which can be built both standalone and as a target library
may want to install itself into different directories depending upon the
case. When built standalone, or when built native, the library should
be installed in `$(libdir)'. When built as a target library which is
not native, the library should be installed in `$(tooldir)/lib'. The
`--with-cross-host' option may be used to distinguish these cases.
This same test of `--with-cross-host' may be used to see whether it
is OK to use link tests in the configure script. If the
`--with-cross-host' option is not used, then the library is being built
either standalone or native, and a link should work.
File: configure.info, Node: Make Targets in Cygnus Tree, Next: Target libiberty, Prev: Target Library Configure Scripts, Up: Cross Tools in the Cygnus Tree
Make Targets in Cygnus Tree
---------------------------
The top level `Makefile' in the Cygnus tree defines targets for
every known subdirectory.
For every subdirectory DIR which holds a host library or program,
the `Makefile' target `all-DIR' will build that library or program.
There are dependencies among host tools. For example, building gcc
requires first building gas, because the gcc build process invokes the
target assembler. These dependencies are reflected in the top level
`Makefile'.
For every subdirectory DIR which holds a target library, the
`Makefile' target `configure-target-DIR' will configure that library.
The `Makefile' target `all-target-DIR' will build that library.
Every `configure-target-DIR' target depends upon `all-gcc', since
gcc, the target compiler, is required to configure the tool. Every
`all-target-DIR' target depends upon the corresponding
`configure-target-DIR' target.
There are several other targets which may be of interest for each
directory: `install-DIR', `clean-DIR', and `check-DIR'. There are also
corresponding `target' versions of these for the target libraries ,
such as `install-target-DIR'.
File: configure.info, Node: Target libiberty, Prev: Make Targets in Cygnus Tree, Up: Cross Tools in the Cygnus Tree
Target libiberty
----------------
The `libiberty' subdirectory is currently a special case, in that it
is the only directory which is built both using the host compiler and
using the target compiler.
This is because the files in `libiberty' are used when building the
host tools, and they are also incorporated into the `libstdc++' target
library as support code.
This duality does not pose any particular difficulties. It means
that there are targets for both `all-libiberty' and
`all-target-libiberty'.
In a native configuration, when target libraries are not built in a
subdirectory, the same objects are normally used as both the host build
and the target build. This is normally OK, since libiberty contains
only C code, and in a native configuration the results of the host
compiler and the target compiler are normally interoperable.
Irix 6 is again an exception here, since the SGI native compiler
defaults to using the `O32' ABI, and gcc defaults to using the `N32'
ABI. On Irix 6, the target libraries are built in a subdirectory even
for a native configuration, avoiding this problem.
There are currently no other libraries built for both the host and
the target, but there is no conceptual problem with adding more.
File: configure.info, Node: Canadian Cross, Next: Cygnus Configure, Prev: Cross Compilation Tools, Up: Top
Canadian Cross
**************
It is possible to use the GNU configure and build system to build a
program which will run on a system which is different from the system on
which the tools are built. In other words, it is possible to build
programs using a cross compiler.
This is referred to as a "Canadian Cross".
* Menu:
* Canadian Cross Example:: Canadian Cross Example.
* Canadian Cross Concepts:: Canadian Cross Concepts.